/**
 * Created by john on 2018/3/28.
 */
var express = require('express');
var router = express.Router();
var CONF = require("../config/conf");
/*必须登录才能访问*/
/* GET home page. */
var VCode = require("../config/code");
router.use('/**', function(req, res, next) {
    if(req.session.userinfo){
        next();
    }else if(req.headers["x-requested-with"] == "XMLHttpRequest"){
        res.json(VCode.login)
    }else{
        var url = CONF.ssoLogin;
        var cd = res.locals._fromUrl;
        console.log(req._fromUrl);
        url = url + cd;
        res.redirect(url);
    }
});

router.get('/page', function(req, res, next) {
    res.render('app/index');
});

module.exports = router;
